

CREATE TABLE users (
    id INT AUTO_INCREMENT PRIMARY KEY,
    username VARCHAR(50) NOT NULL UNIQUE,
    email VARCHAR(100) NOT NULL UNIQUE,
    password VARCHAR(255) NOT NULL,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

CREATE TABLE user_wallets (
    user_id INT PRIMARY KEY,
    subventions DECIMAL(15,2) DEFAULT 0,
    team_rewards DECIMAL(15,2) DEFAULT 0,
    daily_cashback DECIMAL(15,2) DEFAULT 0,
    wallet_balance DECIMAL(15,2) DEFAULT 0,
    FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
);

-- Insert a demo user (optional)
INSERT INTO users (username, email, password) VALUES 
('demo', 'demo@example.com', '$2y$10$...hashedpassword...');
INSERT INTO user_wallets (user_id, subventions, team_rewards) 
SELECT id, 1500000.00, 15600.00 FROM users WHERE username='demo';